import { createRouter, createWebHistory } from 'vue-router'
import Login from "@/views/Login/Login.vue";
import Home from "@/views/Home/Home.vue";
import Manager from "@/views/Manager/Manager.vue";
import Category from "@/views/Category/Category.vue";
import cart from "@/views/Cart/Cart.vue";
import user from "@/views/User/User.vue";
import Cuowu from "@/views/404/Cuowu.vue"
import Commodity from "@/views/Commodity/commodity.vue";
import Checkout from "@/views/Checkout/Checkout.vue";
import Dizhi from "@/views/Dizhi/Dizhi.vue";
import Dingdan from "@/views/Dingdan/Dingdan.vue";
import Register from "@/views/Register/Register.vue";
import Shoucang from "@/views/Shoucang/shoucang.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect:'/manager/home' },
    { path: '/notFound', component: Cuowu },
    { path: '/manager', component: Manager ,
      children:[
        {path: 'home', meta:{name:'首页'}, component: Home ,},
        {path: 'category', meta:{name:'分类'}, component: Category ,},
        {path: 'cart', meta:{name:'购物车'}, component: cart ,},
        {path: 'user', meta:{name:'我的'}, component: user ,},
      ]
    },
    { path: '/dingdan/:title', name:'Dingdan', component: Dingdan , props: true},
    { path: '/checkout', name: '用户结算页', component: Checkout ,},
    { path: '/shoucang', name: '收藏页', component: Shoucang ,},
    { path: '/dizhi', name: '地址', component: Dizhi ,},
    { path: '/commodity/:id', name: '商品购买页', component: Commodity ,},
    { path: '/login', name: '登路页', component: Login, }, // 添加登录页路由
    { path: '/register', name: '注册页' , component: Register, }, // 添加注册页路由
    { path: '/:pathMatch(.*)*', name: '暂没此路由', redirect: '/notFound' }
  ],
})

export default router
